/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.eventos.bc;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.cip.esymons.eventos.be.TipoIngresoEventos;

/**
 *
 * @author lizardor
 */
public class TipoIngresosDelegate {

    TipoIngresoEventosFacadeLocal local;

    public TipoIngresosDelegate() {
        local = lookupTipoIngresoEventosFacade();
    }

    public TipoIngresoEventos buscarTipoIngreso(Integer tpiCodigo) throws Exception {
         try {
            return  local.find(tpiCodigo);
        } catch (Exception ex) {
            return null;
        }
    }

    public void guardar(TipoIngresoEventos ti) throws Exception {
        try {
            local.create(ti);
        } catch (Exception ex) {

        }
    }

    public void actualizar(TipoIngresoEventos ti) throws Exception {
        try {
            local.edit(ti);
        } catch (Exception ex) {

        }
    }

    public void eliminar(TipoIngresoEventos ti) throws Exception {
        try {
            local.remove(ti);
        } catch (Exception ex) {

        }
    }

    public List<TipoIngresoEventos> listar_Todos() throws Exception {
        try {
            return local.findAll();
        } catch (Exception ex) {
            return null;
        }
    }

    private TipoIngresoEventosFacadeLocal lookupTipoIngresoEventosFacade() {
        try {
            Context c = new InitialContext();
            return (TipoIngresoEventosFacadeLocal) c.lookup("java:comp/env/TipoIngresoEventosFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }


}
